

#ifndef SERVICE_MANAGER_PROCESS_HELPER_H_
#define SERVICE_MANAGER_PROCESS_HELPER_H_
#include <string>

/**
 * @brief freeze process by process name
 *
 * @param [in] process_name - process name.
 * @return 0 - Freeze successfully;-1 - cannot found process;-2 - Freeze failed
 */
int FreezeProcessByName(const std::string& process_name);

/**
 * @brief Function to try to resume a stopped process
 *
 * @param [in] process_name - process name.
 * @return 0 - successfully; -1 - not found process; -2 resume failed
 */
int TryToResumeProcessByName(const std::string& process_name, int attempts = 3);

/**
 * @brief freeze process by pid
 *
 * @param [in] pid - pid find by process name.
 * @return true - Freeze successfully; false - Freeze failed
 */
bool FreezeProcessByPid(pid_t pid);

/**
 * @brief try to resume a stopped process by pid
 *
 * @param [in] attempts - if resume failed, try another attempts times.
 * @param [in] pid - pid find by process name.
 * @return true - Resume successfully; false - Resume failed
 */
bool TryToResumeProcessByPid(pid_t pid, int attempts = 3);

/**
 * @brief terminate a process
 *
 * @param [in] process_name - process name.
 * @param [in] attempts - if resume failed, try another attempts times.
 * @return 0 -  successfully; -1 - not found process; -2 terminate failed
 *         -3 - Handle waitpid error
 */
int TerminateProcess(const std::string& process_name, int attempts = 3);


/**
 * @brief Function to find the PID of a process by its name
 * @param [in] process_name  process name
 * @param [out] pid  process id
 * @return  true - find pid by process name; false - not find pid by process name
 */
bool FindPidByProcessName(const std::string& process_name, pid_t &pid);  // NOLINT

/**
 * @brief Function to check if the process is not in stopped state
 *
 * @param [in] pid - pid find by process name
 * @return true - stopped; false - not stopped
 */
bool IsProcessStopped(pid_t pid);

#endif  // SERVICE_MANAGER_PROCESS_HELPER_H_
